package com.lichongbing.lyoggl.mapper;

import com.lichongbing.lyoggl.model.Flags;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * @Entity com.lichongbing.lyoggl.model.Flags
 */
@Component
public interface FlagsMapper extends BaseMapper<Flags> {
    @Select("select * from flags where uid = #{userid} and active = '1' ")
    List<Flags> getFlagsByUid(String userid);
    @Select("select * from flags where uid = #{userid} and active in ('1','0')")
    List<Flags> getFlagsallByUid(String userid);
    @Update("update flags set active = '-1' where  id = #{flagid}")
    void removeById(String flagid);
    @Update("update flags set active = #{active} where  id = #{fid}")
    void updateFlags(String fid, String active);
    @Select("select count(*) from flags where uid = #{userid} and active = 1")
    int getFlagsRowsByUid(String userid);
    @Select("select name from flags where id = #{pid}")
    String getFlagsProjectNamebypid(String pid);
    @Select("select * from flags where uid = #{userid} and  id in (select id from tags)    and  active in ('1','0')")
    List<Flags> getFlagsByUidMain(String userid);
}
